package com.rizzo.analytics.domain.trend;

public enum TrendType {

    MIN("min"),
    MAX("max"),
    MEAN("mean"),
    DEVIATION("deviation"),
    HITS("hits"),
    ALL("all");

    public static final String allowableValues = "ALL,MIN,MAX,MEAN,DEVIATION,HITS";

    private String prefix;

    TrendType(String prefix) {
        this.prefix = prefix;
    }

    public String getPrefix() {
        return prefix;
    }

    public static TrendType fromPrefix(String token) {
        for (TrendType c : TrendType.values()) {
            if (c.prefix.equals(token)) {
                return c;
            }
        }
        throw new IllegalArgumentException("'" + token + "' could not be converted to a TrendType!");
    }

    public static boolean isTrendType(String prefix) {
        for (TrendType c : TrendType.values()) {
            if (c.prefix.equals(prefix)) {
                return true;
            }
        }
        return false;
    }

}
